#! /bin/bash
LIB_PATH=/opt/akimimi_common/
PHP_SCRIPT_PATH=/opt/akimimi_common/tempphp/
PHP_FILE=$PHP_SCRIPT_PATH$2
PHP=/usr/local/php/bin/php
LOG_FILE=/opt/akimimi_common/phplog

if [ -x PHP_SCRIPT_PATH ]; then
  mkdir -p $PHP_SCRIPT_PATH
fi

echo "<?php" > $PHP_FILE
echo "\$LIB_PATH='$LIB_PATH';" >> $PHP_FILE
echo "require_once \$LIB_PATH.'core/Thumbnail.php';" >> $PHP_FILE
echo "require_once \$LIB_PATH.'config.php';" >> $PHP_FILE

echo "\$thumbnail = new Thumbnail();" >> $PHP_FILE
echo "\$thumbnail->uploadOneProductImage($1);" >> $PHP_FILE
echo "?>" >> $PHP_FILE
date >> $LOG_FILE
$PHP $PHP_FILE >> $LOG_FILE
